#!/usr/bin/python3
# -*- coding:utf-8 -*-

import requests
import os
import time
from requests.adapters import HTTPAdapter
class GetContent:
    def go(self,url=''):
        cookies_dict = {}
        cookies = ''
        headers = {
            'User-Agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.75 Safari/537.36',
            'Accept':'text/html',
            'Accept-Encoding':'gzip, deflate, br',
            'Accept-Language':'zh-CN,zh;q=0.9,en;q=0.8'
            # 'Referer':'http://www.sduod.com/baike/anli/'
        }

        cookies_arr = cookies.split(';')
        
        for one_c in cookies_arr:
            try:
                one_arr = one_c.split('=')
                k = one_arr[0]
                v = one_arr[1]
                cookies_dict[k] = v
            except Exception as e:
                pass

        s = requests.Session()
        s.mount('http://',HTTPAdapter(max_retries=2)) 
        s.mount('https://',HTTPAdapter(max_retries=2))      
        try:
            response = s.get(url,cookies = cookies_dict,headers = headers,timeout=10)
        except Exception as e:
            response = {
                'text':''
            }
        response.encoding = 'utf-8'
        return response.text

